﻿<%@ page contentType="text/html; charset=utf-8" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<c:set var="basePath" value="${pageContext.request.contextPath}"/>
<!DOCTYPE HTML>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>数据字典管理</title>
    <jsp:include page="/resources/inc/head.jsp" />
</head>
<body>
<div id="main">
    <div id="toolbar">
        <shiro:hasPermission name="product:dict:create">
            <a class="waves-effect waves-button" href="javascript:;"
               onclick="openPage('新增字典','${basePath}/manage/product/dict/create')">
                <i class="zmdi zmdi-plus"></i>新增字典
            </a>
        </shiro:hasPermission>
        <shiro:hasPermission name="product:category:delete">
            <a class="waves-effect waves-button" href="javascript:;"
               onclick="batchDelete('${basePath}/manage/product/dict/delete')">
                <i class="zmdi zmdi-close"></i>删除字典</a>
        </shiro:hasPermission>
    </div>
    <table id="table"></table>
</div>
<jsp:include page="/resources/inc/footer.jsp" />
<script>
    var query = {};
    var $table = $('#table');
    $(function () {
        // bootstrap table初始化
        $table.bootstrapTable({
            url: '${basePath}/manage/product/dict/list',
            height: getHeight(),
            striped: true,//隔行变色
            search: true,
            showRefresh: true,
            showColumns: true,//是否显示 内容列下拉框
            minimumCountColumns: 2,//当列数小于此值时，将隐藏内容列下拉框
            clickToSelect: true,//设置true 将在点击行时，自动选择rediobox 和 checkbox
            detailView: true,//设置为 true 可以显示详细页面模式。
            detailFormatter: 'detailFormatter',//格式化详细页面模式的视图。
            pagination: true,//设置为 true 会在表格底部显示分页条
            paginationLoop: false,//设置为 true 启用分页条无限循环的功能。
            sidePagination: 'server',
            silentSort: false,//设置为 false 将在点击分页按钮时，自动记住排序项。仅在 sidePagination设置为 server时生效.
            smartDisplay: false,//True to display pagination or card view smartly.
            queryParamsType: "",
            escape: true,//转义HTML字符串，替换 &, <, >, ", `, 和 ' 字符.
            searchOnEnterKey: true,//设置为 true时，按回车触发搜索方法，否则自动触发搜索方法
            idField: 'id',//指定主键列
            maintainSelected: true,//设置为 true 在点击分页按钮或搜索按钮时，将记住checkbox的选择项
            toolbar: '#toolbar',
          /*  queryParams:function(params){
                params.id = query.id;
                return params;
            },*/
            columns: [
                {field: 'ck', checkbox: true},
                {field: 'description', title: '描述', align: 'center'},
                {field: 'key', title: 'key', align: 'center'},
                {field: 'sort', title: '排序', align: 'center',sortable: true},
                {
                    field: 'action',
                    title: '操作',
                    align: 'center',
                    formatter: 'actionFormatter',
                    events: 'actionEvents',
                    clickToSelect: false
                }
            ]
        });
    });
    // 格式化操作按钮
    setPageWidth("590px");
    setPageLength("55%");
    var zNodes;
    var updateData = {
        title: "'编辑字典'",
        url: "'${basePath}/manage/product/dict/update/'",
        id: ""
    };
    var deleteData = {
        url: "'${basePath}/manage/product/dict/delete'",
        id: ""
    };
    // 格式化操作按钮
    function actionFormatter(value, row, index) {
        updateData.id = row.id;
        deleteData.id = row.id;
        var updateHtml = '<a class="update" href="javascript:;" ' +
                'onclick="openPage(' + updateData.title + ',' + updateData.url + ',' + updateData.id + ')" ' +
                'data-toggle="tooltip" title="Edit"><i class="glyphicon glyphicon-edit"></i></a>';
        var deleteHtml = '<a class="delete" href="javascript:;"' +
                'onclick="deleteOne(' + deleteData.url + ',' + deleteData.id + ')" ' +
                ' data-toggle="tooltip" title="Remove"><i class="glyphicon glyphicon-remove"></i></a>';
        return updateHtml + "  " + deleteHtml;
    }
</script>
</body>
</html>